package com.yzf.wisecoder.exception;

import com.yzf.wisecoder.wisecodercommon.exception.RRException;
import com.yzf.wisecoder.wisecodercommon.response.Response;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * @Author: jianghuiyong
 * @Date: 2018/11/26 19:12
 * @Version 1.0
 */
@RestControllerAdvice
@Slf4j
public class RRExceptionHandler {


    @ExceptionHandler(RRException.class)
    public Response handleRRException(RRException e) {
        log.error(e.getMsg(), e);
        return Response.buildErrorResponse(e.getMsg());
    }


    @ExceptionHandler(Exception.class)
    public Response handleException(Exception e) {
        log.error(e.getMessage(), e);
        return Response.buildErrorResponse(e.getMessage());
    }

}
